package com.shenmazong.proxy;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Proxy;

/**
 * @program: server-java-demo
 * @description: MarryInvocationApplication
 * @author: 亮子说编程
 * @create: 2020-10-15 15:04
 **/
public class MarryInvocationApplication {

    public static void main(String[] args) {
        // 是否保存生成的代理类class文件，默认false不保存
        System.getProperties().setProperty("sun.misc.ProxyGenerator.saveGeneratedFiles", "true");

        IMarry marry = new MarryPerson();

        InvocationHandler handler = new MarryInvocationHandler(marry);

        IMarry proxyHello = (IMarry) Proxy.newProxyInstance(marry.getClass().getClassLoader(), marry.getClass().getInterfaces(), handler);

        proxyHello.doMarry();
    }
}
